<template>
  <h2>👶孙组件</h2>
  <div>{{ money }}</div>
  <div>{{ car }}</div>
  <button @click="changMoney">点击</button>
</template>

<script setup lang='ts'>
import { inject, Ref } from "vue";

const money = inject<Ref<number>>("money");
const car = inject<Ref<string>>("car");

const changMoney = () => {
  console.log("获取到真实值", money?.value);

  if (money) money.value -= 100;
};
</script>
